Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow scoped application services to be accessed from the context #9009

Merged
merged 1 commit into from Jun 29, 2017

Conversation

ajcvickers
Copy link
Member

Issue #8797

After going back and forth on this I settled on:

  • Register DbContextOptions as scoped by default
    • This allows scoped services to be used in AddDbContext
    • This allows scoped services to be resolved from context.GetService
    • It will still work fine if scoped services are not needed
  • Add another parameter to AddDbContext to allow the options to be registered as Singleton if needed
    • This can be used for apps that are doing some heavy lifting in AddDbContext

Issue #8797

After going back and forth on this I settled on:
* Register DbContextOptions as scoped by default
  * This allows scoped services to be used in AddDbContext
  * This allows scoped services to be resolved from context.GetService
  * It will still work fine if scoped services are not needed
* Add another parameter to AddDbContext to allow the options to be registered as Singleton if needed
  * This can be used for apps that are doing some heavy lifting in AddDbContext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants